package cn.wolfcode.trip.core.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;

@Setter
@Getter
public class Region extends BaseDomain{

    public static final int STATE_DISABLE = -1; // 禁用
    public static final int STATE_COMMON = 0; // 普通
    public static final int STATE_HOT = 1; // 推荐

    private String name; // 地区名称

    private Region parent; // 上级地区

    private Integer state = STATE_COMMON; // 状态

    public String getJson(){

        HashMap<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("state",state);
        if(parent!=null){
            map.put("parentId",parent.getId());
            map.put("parentName",parent.getName());
        }
        return JSON.toJSONString(map);
    }

}